import axios from 'axios'
import { Message } from "element-ui"
//基本路径
//本地服务器路径 127.0.0.1
//网路路径  82.156.30.240
axios.defaults.baseURL = "http://127.0.0.1:8888/api/private/v1/"
//请求拦截
axios.interceptors.request.use(function (config) {


    config.headers.Authorization = localStorage.getItem('houtaitoken')
    return config
}, function (error) {
    return Promise.reject(error)
})
//响应拦截
axios.interceptors.response.use(function (response) {
    if (response.data.meta.status < 300) {
        Message({
            message: response.data.meta.msg,
            type: 'success'
        });

    } else {
        Message.error(response.data.meta.msg);
    }
    return response.data
}, function (error) {
    return Promise.reject(error)
})
//导出
export default axios